using System;
using DynamicGeneration.Framework.DAL;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace MusicLine.DAL
{
    internal abstract class AbstractDataStore : AbstractHydratable
    {
        private const string CONNECTION_STRING_NAME = "ML";
        public Database DataStore { get; private set; }
        internal void SetDataStore(Database database)
        {
            if (database == null)
                throw new ArgumentNullException("database", "database is null.");
            DataStore = database;
        }
        /// <summary>
        /// Initializes a new instance of the AbstractDataStore class.
        /// </summary>
        public AbstractDataStore(Database dataStore)
        {
            SetDataStore(dataStore);
        }

        /// <summary>
        /// Initializes a new instance of the AbstractDataStore class.
        /// </summary>
        public AbstractDataStore() : this(DatabaseFactory.CreateDatabase(CONNECTION_STRING_NAME)) { }
    }
}
